package gameobj;

import manager.ElementManager;
import manager.ImageManager;
import render.SimpleModel;

/**
 * 
 * @author crd
 * 道具类
 *
 */
public class Prop extends Actor {
	public Prop(int x,int y) {
		super();
		// TODO 自动生成的构造函数存根
		this.setW(20);
		this.setH(20);
		this.setX(x);
		this.setY(y);
		this.setMaxHealth(1);
		this.setHealth(1);
		this.setDirection(false);
	}

	@Override
	public void ObjRun() {
		// TODO 自动生成的方法存根
		
	}
	public static Prop newProp(int x,int y) {
		Prop prop=new Prop(x, y);
		ElementManager em = ElementManager.get();
		ImageManager im = ImageManager.get();
		im.addImage("image/prop/4.png");
		prop.setModel(new SimpleModel("4.png-prop"));
		em.add(ElementType.ENEMY, prop);
		return prop;
	}

	@Override
	protected void attack() {
		// TODO 自动生成的方法存根
		
	}

	@Override
	public void getHurt(int damage) {
		// TODO 自动生成的方法存根
		this.setHealth(getHealth()-damage);
		if(this.getHealth()<=0)
		{
			this.setHealth(0);
			this.death();
		}
	}
	@Override
	public void death() {
		// TODO 自动生成的方法存根
		super.death();
//		如果Player攻击并未得到增益
		if (!Player.addattack) {
			Player.addattack=true;
		} else {
			Player player = (Player)ElementManager.get().getList(ElementType.PLAYER).get(0);
			player.getHurt(-1);
		}		
	}
}
